package com.leetcode.LC;

import java.util.Arrays;

public class LC976 {
    public int largestPerimeter(int[] A) {

        //int max = 0;
        Arrays.sort(A);
        for (int i = A.length - 1; i >= 2; i--) {
            if (A[i] < A[i - 1] + A[i - 2]) {
                //max = Math.max(max, A[i] + A[i - 1] + A[i - 2]);
                return A[i] + A[i - 1] + A[i - 2];
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(new LC976().largestPerimeter(new int[]{3,2,3,4}));
    }
}
